package com.chexiaoy.lab.domain;

import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController;
import com.gargoylesoftware.htmlunit.WebClient;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;

/**
 * Created by alickgeng on 2016/11/17.
 */
public class ResynchronizingHtmlUnitDriver extends HtmlUnitDriver {

    public ResynchronizingHtmlUnitDriver(boolean b) {
        super(b);
        WebClient webClient = this.getWebClient();
        webClient.getOptions().setCssEnabled(false);//设置css是否生效
        webClient.getOptions().setJavaScriptEnabled(true);//设置js是否生效
        webClient.setAjaxController(new NicelyResynchronizingAjaxController());//设置ajax请求
        webClient.getOptions().setTimeout(10000);

    }

    public void waitForBackgroundJavaScript(int i) {
        getWebClient().waitForBackgroundJavaScript(i);
    }

    public WebClient getWebClient() {
        return super.getWebClient();
    }
}
